<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <script>

        // 组合继承  构造函数 + 原型对象 



        function Dog (color) {
            this.type = '狗子' ;
            this.say = '汪' ;
            this.color = color ;
        }

        Dog.prototype.speak = function() {
            console.log('hello world');
        }


        function KeJi(name , age , color) {
            this.name = name ;
            this.age = age ;

            // 想调用Dog的属性和方法
            // this.type = '狗子' ;
            // this.say = '汪' ;

            // 直接调用  this指向window   把指向变成当前的keji
            Dog.call(this , color) ;

        }


        KeJi.prototype = {...Dog.prototype} ;


        const k = new KeJi('kj' , 3 , 'yellow') ;
        console.log(k);




    </script>
    
</body>
</html>